package model;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class Persistencia {
	
	
	public void Persistir(Produto p){
	
	EntityManagerFactory emf =Persistence.createEntityManagerFactory("default");
	EntityManager em = emf.createEntityManager();

	em.getTransaction().begin();
	
	em.persist(p);
	em.getTransaction().commit();
	
	emf.close ();
	em.close();
	}
	
	
	public void Persistir(Departamento p){
		
		EntityManagerFactory emf =Persistence.createEntityManagerFactory("default");
		EntityManager em = emf.createEntityManager();

		em.getTransaction().begin();
		
		em.persist(p);
		em.getTransaction().commit();
		
		emf.close ();
		em.close();
		}


}
